package stream;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.windowing.time.Time;

public class oneparalleSourceDemo {
    public static void main(String[] args) throws Exception {
    //   创建流式数据环
        StreamExecutionEnvironment env =  StreamExecutionEnvironment.getExecutionEnvironment();
    //    添加数据源
        DataStreamSource<Long> source = env.addSource(new oneparalleSource());

        DataStream<Long> result = source.map(new MapFunction<Long, Long>() {
            public Long map(Long aLong) throws Exception {
                System.out.println(aLong);
                return aLong ;
            }
        }).timeWindowAll(Time.seconds(2)).sum(0);
        //result.timeWindowAll(Time.seconds(2)).sum(0);
        result.print();
        env.execute("oneparalleSoure");
    }
}
